using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Security.Permissions;

using CureConsulting;
using CureConsulting.Common;

namespace Blog.Net.Common.DataObjects
{
	[Serializable]
	public partial class BlogCategory : DataObjectBase
	{
		#region Constructors

		/// <summary>
		/// Create a BlogCategory object Empty Constructor
		/// </summary>
		public BlogCategory() { }

		/// <summary>
		/// Create a BlogCategory object Full Constructor
		/// </summary>
		/// <param name="Name"></param>
		/// <param name="Description"></param>
		public BlogCategory( string Name, string Description ) : this()
		{
			this.Name = Name;
			this.Description = Description;
		}
		/// <summary>
		/// Create a BlogCategory object from serialization
		/// </summary>
		protected BlogCategory(SerializationInfo info, StreamingContext context) : base(info, context)
      	{
			_name = (string)info.GetValue("_name", typeof(string));
			_description = (string)info.GetValue("_description", typeof(string));
			_blogEntries = (IList<BlogEntry>)info.GetValue("_blogEntries", typeof(IList<BlogEntry>));
      	}
		#endregion
		
		#region Member Variables
		
		protected string _name;
		protected string _description;
		protected IList<BlogEntry> _blogEntries;

		#endregion

		#region Public Properties
		
		/// <summary>
		/// BlogCategory Name
		/// </summary>
		public virtual string Name
		{
			get { return _name; }
			set
			{
				if (value != null && value.Length > 255)
					throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
				UpdateState(_name , value);
				_name = value;
			}
		}

		/// <summary>
		/// BlogCategory Description
		/// </summary>
		public virtual string Description
		{
			get { return _description; }
			set 
			{
				UpdateState(_description , value);
				_description = value;
			}
		}

		/// <summary>
		/// BlogCategory BlogEntries
		/// </summary>
		public virtual IList<BlogEntry> BlogEntries
		{
			get
			{
				if (_blogEntries==null)
				{
					_blogEntries = new SortableBindingList<BlogEntry>();
				}
				return _blogEntries;
			}
			set { _blogEntries = value; }
		}

		
		#endregion
		
		#region Methods
		/// <summary>
        /// Set object data for serialization
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
      	[SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)]
		public override void GetObjectData(SerializationInfo info, StreamingContext context)
      	{
			info.AddValue("_name", _name);
			info.AddValue("_description", _description);
			info.AddValue("_blogEntries", _blogEntries);			
         	base.GetObjectData(info, context);
      	}
		#endregion
	}
}